/*
 * @Author: long-xinyu2 2192763423@qq.com
 * @Date: 2025-03-11 18:47:55
 * @LastEditors: long-xinyu2 2192763423@qq.com
 * @LastEditTime: 2025-03-25 18:46:43
 * @FilePath: \algorithm\algorithm-training\2025_3_11.cpp
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#include<iostream>
#include<cstring>
#include<vector>
#include<map>
#include<cstdio>
#include<algorithm>
#include<string>
#include<string.h>
#include<queue>
#include<math.h>
#include<set>
#include<functional>
using namespace std;
using ull = unsigned long long;
#define int long long
//using i128 = __int128_t;
inline int inc(int x, int v, int mod) { x += v;return x >= mod ? x - mod : x; }//代替取模+
#define endl '\n'
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;

const int N = 2e3 + 10, M = 1e5 + 10;

inline int read()
{
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9')
    {
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9')
        x = x * 10 + ch - '0', ch = getchar();
    return x * f;
}


void solve()
{
    int n,m;
    cin >> n >> m;
    int tt = m;
    vector<int>arr;
    while(tt)
    {
        arr.push_back(tt % 2);
        tt /= 2;
    }
    vector<int>res;
    int cnt = 0;
    int pos = 0;
    int pp = 0;
    while(1)
    {
        if(res.size() == n)
        {
            pp = 1;
            break;
        }
        int ux = cnt;
        vector<int>pp;
        while(ux)
        {
            pp.push_back(ux % 2);
            ux /= 2;
        }
        if(pp.size() > arr.size())
        {
            break;
        }
        int flag = 0;
        for(int j = pp.size() - 1; j >= 0; j --)
        {
            if(pp[j] == 1 && arr[j] == 0)
            {
                flag = 1;
                break;
            }
        }
        if(flag == 1)
        {
            break;
        }
        else
        {
            res.push_back(cnt);
            cnt ++;
        }
    }
    if(pp == 0)
    {
        int ans = res[0];
        for(int i = 1; i < res.size(); i ++)
        {
            ans |= res[i];
        }
        if(ans == m)
        {
            while(res.size() < n)
            {
                res.push_back(0);
            }
            for(int i = 0; i < res.size(); i ++)
            {
                cout << res[i] << ' ';
            }
            cout << endl;
        }
        else
        {
            while(res.size() < n)
            {
                res.push_back(m);
            }
            for(int i = 0; i < res.size(); i ++)
            {
                cout << res[i] << ' ';
            }
            cout << endl;
        }
    }
    else
    {
        int ans = res[0];
        for(int i = 1; i < res.size(); i ++)
        {
            ans |= res[i];
        }
        if(ans == m)
        {
            while(res.size() < n)
            {
                res.push_back(0);
            }
            for(int i = 0; i < res.size(); i ++)
            {
                cout << res[i] << ' ';
            }
            cout << endl;
        }
        else
        {
            res.pop_back();
            while(res.size() < n)
            {
                res.push_back(m);
            }
            for(int i = 0; i < res.size(); i ++)
            {
                cout << res[i] << ' ';
            }
            cout << endl;
        }
    }
}
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int tt;
    cin >> tt;
    //tt = 1;
    while (tt--)
    {
        solve();
    }
}